/*
 * 描          述:  <描述>
 * 修  改   人:  PengQingyang
 * 修改时间:  2022年4月27日
 * <修改描述:>
 */
package com.tx.core.method.databinder.impl;

import org.springframework.lang.Nullable;
import org.springframework.validation.DataBinder;

import com.tx.core.method.databinder.NativeDataBinderFactory;
import com.tx.core.method.request.NativeInvokeRequest;

/**
 * 默认的DataBinder工厂<br/>
 * <功能详细描述>
 * 
 * @author  PengQingyang
 * @version  [版本号, 2022年4月27日]
 * @see  [相关类/方法]
 * @since  [产品/模块版本]
 */
public class DefaultNativeDataBinderFactory implements NativeDataBinderFactory {
    
    /**
     * @param request
     * @param target
     * @param objectName
     * @return
     * @throws Exception
     */
    @Override
    public DataBinder createBinder(NativeInvokeRequest request, Object target,
            String objectName) throws Exception {
        DataBinder dataBinder = createBinderInstance(target,
                objectName,
                request);
        initBinder(dataBinder, request);
        return dataBinder;
    }
    
    /**
     * 创建dataBinder实例<br/>
     * <功能详细描述>
     * @param target
     * @param objectName
     * @param webRequest
     * @return
     * @throws Exception [参数说明]
     * 
     * @return DataBinder [返回类型说明]
     * @exception throws [异常类型] [异常说明]
     * @see [类、类#方法、类#成员]
     */
    protected DataBinder createBinderInstance(@Nullable Object target,
            String objectName, NativeInvokeRequest webRequest)
            throws Exception {
        return new DataBinder(target, objectName);
    }
    
    /**
     * 初始化dataBinder<br/>
     * <功能详细描述>
     * @param dataBinder
     * @param webRequest
     * @throws Exception [参数说明]
     * 
     * @return void [返回类型说明]
     * @exception throws [异常类型] [异常说明]
     * @see [类、类#方法、类#成员]
     */
    protected void initBinder(DataBinder dataBinder,
            NativeInvokeRequest webRequest) throws Exception {
    }
    
}
